import { getGoodsList, getGoodsTypeKeyList } from "@/api/receivenotice/wmsReceiveNoticeOrder";
import { waitInTaskDetail } from "@/api/inbound/mesInTaskDetail";
import { uniqueKey } from "@/utils/judge"

export const goodsDialog = {
  data() {
    return {
      goodsDialogVisible: false, //表格弹框隐藏显示
      waitInTaskDetail,
      goodsHasFooter: true, // 是否需要底部按钮默认true
      operateList1: [
        {
          name: $i18n.t("common.cancel"),
          handleName: "cls" //点击时返回的标识
        },
        {
          name: $i18n.t("common.submit"),
          type: "primary",
          isMultiple: true, //至少选择一条
          //是否可点击；
          disabled: (data) => {
            console.log(data)
            return data.length < 1
          },
          handleName: "add" //点击时返回的标识
        }
      ],
      goodsSearchDialog: {
        inline: true,
        span: 24,
        formDesc: {
          goodsCode: {
            type: "input",
            layout: 12,
            label: "物料编码"
          },
          goodsName: {
            type: "input",
            layout: 12,
            label: "物料名称"
          },
        }
      },
      goodsDialogColumn: [
        {
          type: "selection",
          fixed: "left"
        },
        {
          type: "index",
          label: $i18n.t("common.order"),
          width: 60,
          fixed: "left"
        },
        {
          prop: "goodsCode",
          label: $i18n.t("common.materialCode"),
          width: 180,
          showOverflowTooltip: true,
          fixed: "left"
        },
        {
          prop: "goodsName",
          label: $i18n.t("common.materialName"),
          width: 180,
          showOverflowTooltip: true
        },
        {
          prop: "planAmount",
          label: "物料数量",
          width: 180,
          showOverflowTooltip: true
        }
      ]
    }
  },
  methods: {
    // 弹框表格，双击表格，或者点击确定 返回选中数据

    handleOperateEvent1(data) {
      const fnc = {
        //   取消
        cls: () => {
          this.goodsDialogVisible = false
        },
        // 确认
        add: () => {
          if (data.rows.length != 0) {
            console.log("子组件data", data)
            this.setSelectGoods(data.rows)
            // this.$emit("getSelectData", data.rows);
            this.goodsDialogVisible = false
          } else {
            this.$message.warning($i18n.t("common.multiple"))
          }
        }
      }
      fnc[data.handleName]()
    }
  }
}
